package com.c2.service.impl;


import com.c2.entity.EbOrder;
import com.c2.mapper.OrderMapper;
import com.c2.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public List<EbOrder> listByPage(int page, int pageSize){
        int from =(page-1)*pageSize;
        return orderMapper.findByPage(from,pageSize);
    }

    @Override
    public List<EbOrder> selectByIdName2(Integer eoId,String eoUserName ,int page, int pageSize){
        int from =(page-1)*pageSize;
        if (eoId==null) return orderMapper.findByIdName1(eoUserName,from,pageSize);
        else if (eoUserName=="") return orderMapper.findByIdName(eoId,from,pageSize);
        return orderMapper.findByIdName2(eoId,eoUserName,from,pageSize);
    }
    @Override
    public EbOrder selectById(Integer eoId){
        return orderMapper.findById(eoId);
    }


    @Override
    public int updateById(EbOrder ebOrder) {
        System.out.println(ebOrder);
        return orderMapper.updateByPrimaryKey(ebOrder);
    }

    @Override
    public int delete(Integer Id) {
        return orderMapper.delete(Id);
    }
    @Override
    public int getMaxPage(int pageSize){
        return orderMapper.getMaxPage(pageSize);
    }
    @Override
    public int getByName(String eoUserName, int pageSize){
        return orderMapper.getByName(eoUserName,pageSize);
    }

}
